package com.rdc.qingkou.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by asus on 2017/8/11.
 */

public class LabelSharedPreferencesUtils {
    private SharedPreferences preferences;
    private SharedPreferences.Editor editor ;
    private int i;

    public LabelSharedPreferencesUtils(Context context) {
        this.preferences = context.getSharedPreferences("label",context.MODE_PRIVATE);
        this.editor = preferences.edit();
        this.i = preferences.getInt("count",1);
    }

    public void putString(String s){
        if (s.equals(getString("LabelOne"))||s.equals(getString("LabelTwo"))||s.equals(getString("LabelThree"))){
            return;
        }
        if (i%3==1){
            editor.putString("LabelOne",s);
            i++;
            editor.putInt("count",i);

        }else if (i%3==2){
            editor.putString("LabelTwo",s);
            i++;
            editor.putInt("count",i);

        }else {
            editor.putString("LabelThree",s);
            i++;
            editor.putInt("count",i);

        }
        editor.apply();
    }

    public String getString(String key){
        return preferences.getString(key,"");
    }
}


